inherited dm_empresadepartamento: Tdm_empresadepartamento
  OldCreateOrder = True
  Height = 290
  Width = 649
  inherited sqlConsulta: TSQLQuery
    Params = <
      item
        DataType = ftInteger
        Name = 'codigo'
        ParamType = ptInput
      end>
    SQL.Strings = (
      'select'
      '    d.cod_departamento,'
      '    d.lig_cod_empresa,'
      '    d.descricao,'
      '    d.situacao,'
      '    d.data_cad,'
      '    d.data_alteracao,'
      '    case'
      '      when d.situacao = '#39'True'#39' Then '#39'ATIVO'#39' else '#39'INATIVO'#39
      '    end as situacao_desc,'
      '    a.descricao_multiempresa,'
      
        '    (select count(b.lig_cod_departamento) from funcionario b whe' +
        're b.lig_cod_departamento = d.cod_departamento) as total_func'
      'from EMPRESA_DEPARTAMENTO d'
      'left join empresa a on (a.cod_empresa = d.lig_cod_empresa)'
      'where d.lig_cod_empresa = :codigo')
    Left = 384
  end
  inherited dspConsulta: TDataSetProvider
    Left = 384
  end
  inherited cdsConsulta: TClientDataSet
    Left = 384
    object cdsConsultaCOD_DEPARTAMENTO: TIntegerField
      Alignment = taCenter
      FieldName = 'COD_DEPARTAMENTO'
      Required = True
    end
    object cdsConsultaLIG_COD_EMPRESA: TIntegerField
      Alignment = taCenter
      FieldName = 'LIG_COD_EMPRESA'
      Required = True
    end
    object cdsConsultaDESCRICAO: TStringField
      FieldName = 'DESCRICAO'
      Required = True
      Size = 100
    end
    object cdsConsultaSITUACAO: TStringField
      Alignment = taCenter
      FieldName = 'SITUACAO'
      Size = 5
    end
    object cdsConsultaDATA_CAD: TDateField
      Alignment = taCenter
      FieldName = 'DATA_CAD'
    end
    object cdsConsultaDATA_ALTERACAO: TDateField
      Alignment = taCenter
      FieldName = 'DATA_ALTERACAO'
    end
    object cdsConsultaSITUACAO_DESC: TStringField
      Alignment = taCenter
      FieldName = 'SITUACAO_DESC'
      Required = True
      FixedChar = True
      Size = 7
    end
    object cdsConsultaDESCRICAO_MULTIEMPRESA: TStringField
      FieldName = 'DESCRICAO_MULTIEMPRESA'
      Size = 50
    end
    object cdsConsultaTOTAL_FUNC: TIntegerField
      Alignment = taCenter
      FieldName = 'TOTAL_FUNC'
    end
    object cdsConsultasqlConsultaFuncionario: TDataSetField
      FieldName = 'sqlConsultaFuncionario'
    end
  end
  inherited qryPKChave: TSQLQuery
    SQL.Strings = (
      'SELECT GEN_ID(gen_empresa_departamento,1)'
      'FROM RDB$DATABASE')
    Left = 523
  end
  inherited dspRegistro: TDataSetProvider
    Left = 456
  end
  inherited cdsRegistro: TClientDataSet
    OnReconcileError = cdsRegistroReconcileError
    Left = 456
    object cdsRegistroCOD_DEPARTAMENTO: TIntegerField
      FieldName = 'COD_DEPARTAMENTO'
      Required = True
    end
    object cdsRegistroLIG_COD_EMPRESA: TIntegerField
      Alignment = taCenter
      FieldName = 'LIG_COD_EMPRESA'
      Required = True
    end
    object cdsRegistroDESCRICAO: TStringField
      FieldName = 'DESCRICAO'
      Required = True
      Size = 100
    end
    object cdsRegistroSITUACAO: TStringField
      FieldName = 'SITUACAO'
      Size = 5
    end
    object cdsRegistroDATA_CAD: TDateField
      FieldName = 'DATA_CAD'
    end
    object cdsRegistroDATA_ALTERACAO: TDateField
      FieldName = 'DATA_ALTERACAO'
    end
  end
  inherited sqlRegistro: TSQLQuery
    Params = <
      item
        DataType = ftInteger
        Name = 'codigo'
        ParamType = ptInput
      end>
    SQL.Strings = (
      'select'
      '    d.cod_departamento,'
      '    d.lig_cod_empresa,'
      '    d.descricao,'
      '    d.situacao,'
      '    d.data_cad,'
      '    d.data_alteracao'
      'from EMPRESA_DEPARTAMENTO d'
      'where d.cod_departamento = :codigo')
    Left = 456
  end
  object dsMestre_Detalhe: TDataSource
    DataSet = sqlConsulta
    Left = 304
    Top = 17
  end
  object cdsConsultaFuncionario: TClientDataSet
    Aggregates = <>
    DataSetField = cdsConsultasqlConsultaFuncionario
    Params = <>
    Left = 72
    Top = 16
    object cdsConsultaFuncionarioCOD_FUNCIONARIO: TIntegerField
      Alignment = taCenter
      FieldName = 'COD_FUNCIONARIO'
      Required = True
    end
    object cdsConsultaFuncionarioLIG_COD_USUARIO: TIntegerField
      FieldName = 'LIG_COD_USUARIO'
    end
    object cdsConsultaFuncionarioDESCRICAO: TStringField
      FieldName = 'DESCRICAO'
      Required = True
      Size = 100
    end
    object cdsConsultaFuncionarioTEL_RESIDENCIAL: TStringField
      Alignment = taCenter
      FieldName = 'TEL_RESIDENCIAL'
    end
    object cdsConsultaFuncionarioTEL_CELULAR: TStringField
      Alignment = taCenter
      FieldName = 'TEL_CELULAR'
    end
    object cdsConsultaFuncionarioEMAIL: TStringField
      FieldName = 'EMAIL'
      Size = 100
    end
    object cdsConsultaFuncionarioSITUACAO_DESC: TStringField
      Alignment = taCenter
      FieldName = 'SITUACAO_DESC'
      Required = True
      FixedChar = True
      Size = 7
    end
    object cdsConsultaFuncionarioDESCRICAO_MULTIEMPRESA: TStringField
      FieldName = 'DESCRICAO_MULTIEMPRESA'
      Size = 50
    end
    object cdsConsultaFuncionarioLOGIN: TStringField
      Alignment = taCenter
      FieldName = 'LOGIN'
      Size = 30
    end
  end
  object sqlConsultaFuncionario: TSQLQuery
    DataSource = dsMestre_Detalhe
    MaxBlobSize = -1
    Params = <
      item
        DataType = ftInteger
        Name = 'COD_DEPARTAMENTO'
        ParamType = ptInput
        Size = 4
      end>
    SQL.Strings = (
      'select'
      '    f.COD_FUNCIONARIO,'
      '    f.LIG_COD_USUARIO,'
      '    f.DESCRICAO,'
      '    f.TEL_RESIDENCIAL,'
      '    f.TEL_CELULAR,'
      '    f.EMAIL,'
      '    f.SITUACAO,'
      '    case'
      '      when f.situacao = '#39'True'#39' then '#39'ATIVO'#39' else '#39'INATIVO'#39
      '    end situacao_desc,'
      '    a.descricao_multiempresa,'
      '    coalesce(b.login,'#39'-- INDEFINIDO --'#39','#39#39') as login'
      'from funcionario f'
      'left join empresa a on (a.cod_empresa = f.lig_cod_empresa)'
      'left join usuario b on (b.cod_usuario = f.lig_cod_usuario)'
      
        'left join empresa_departamento c on (c.cod_departamento = f.lig_' +
        'cod_departamento)'
      'where f.lig_cod_departamento = :cod_departamento')
    SQLConnection = dmGeral.SQLConnectionBD
    Left = 192
    Top = 17
    object sqlConsultaFuncionarioCOD_FUNCIONARIO: TIntegerField
      Alignment = taCenter
      FieldName = 'COD_FUNCIONARIO'
      Required = True
    end
    object sqlConsultaFuncionarioLIG_COD_USUARIO: TIntegerField
      FieldName = 'LIG_COD_USUARIO'
    end
    object sqlConsultaFuncionarioDESCRICAO: TStringField
      FieldName = 'DESCRICAO'
      Required = True
      Size = 100
    end
    object sqlConsultaFuncionarioTEL_RESIDENCIAL: TStringField
      Alignment = taCenter
      FieldName = 'TEL_RESIDENCIAL'
    end
    object sqlConsultaFuncionarioTEL_CELULAR: TStringField
      Alignment = taCenter
      FieldName = 'TEL_CELULAR'
    end
    object sqlConsultaFuncionarioEMAIL: TStringField
      FieldName = 'EMAIL'
      Size = 100
    end
    object sqlConsultaFuncionarioSITUACAO_DESC: TStringField
      Alignment = taCenter
      FieldName = 'SITUACAO_DESC'
      Required = True
      FixedChar = True
      Size = 7
    end
    object sqlConsultaFuncionarioDESCRICAO_MULTIEMPRESA: TStringField
      FieldName = 'DESCRICAO_MULTIEMPRESA'
      Size = 50
    end
    object sqlConsultaFuncionarioLOGIN: TStringField
      FieldName = 'LOGIN'
      Size = 30
    end
  end
end
